﻿using B.S.DataBase.MyProject.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using T.E.ERP.Write.API.Applicantions.Command.StoragesCommand;

namespace T.E.ERP.Write.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BaseStoragemanageController : ControllerBase
    {
        private readonly IMediator mediator;
        private readonly ILogger<BaseStoragemanageController> logger;

        public BaseStoragemanageController(IMediator mediator, ILogger<BaseStoragemanageController> logger)
        {
            this.mediator = mediator;
            this.logger = logger;
        }
        /// <summary>
        /// 仓库新增
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> AddBaseStore(AddWhereHorseCommand command)
        {
            try
            {
                logger.LogInformation(DateTime.Now + "成功调用仓库新增方法");
            }
            catch (Exception ex)
            {
                logger.LogInformation(DateTime.Now + "调用仓库新增方法失败！" + ex.Message);
            }
            return await mediator.Send(command);
        }

        /// <summary>
        /// 仓库删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<APIResult<object>> DelBaseStore([FromQuery]DelStoreCommand command)
        {
            try
            {
                logger.LogInformation(DateTime.Now + "成功调用仓库删除方法");
            }
            catch (Exception ex)
            {
                logger.LogInformation(DateTime.Now + "调用仓库删除方法失败！" + ex.Message);
            }
            return await mediator.Send(command);
        }
    }
}
